import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/layout/Layout'
import Home from '@/layout/Home'
import VideoList from '@/components/video/videolist/VideoList'
import VideoPlayer from '@/components/video/videoplayer/VideoPlayer'

Vue.use(Router)

export default new Router({
    mode: 'history',
    routes: [{
            path: '/',
            name: '首页',
            redirect: "/home"
        },
        {
            path: '/',
            component: Layout,
            meta: { requiresAuth: true },
            children: [{
                path: "/home",
                component: Home,
                name: '欢迎您',
                meta: { title: "欢迎您" }
            }]
        },
        {
            path: '/video',
            component: Layout,
            children: [{
                    path: 'list',
                    name: '资源列表',
                    meta: { title: "资源列表" },
                    component: VideoList
                },
                {
                    path: 'player',
                    name: '视频播放',
                    meta: { title: "视频播放" },
                    component: VideoPlayer
                },
            ]
        },
    ],
    linkActiveClass: "active-router",
    linkExactActiveClass: "exact-router"
})

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}